feat: add rejectUnauthorized to RequestOptions#741
Conversation
commit: |
|
@copilot add type check unit test for this change. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #741 +/- ##
=======================================
Coverage 94.91% 94.91%
=======================================
Files 10 10
Lines 747 747
Branches 235 235
=======================================
Hits 709 709
Misses 35 35
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR makes rejectUnauthorized part of the exported RequestOptions type so library consumers can pass it without TypeScript errors when typing options as RequestOptions.
Changes:
- Moved
rejectUnauthorized?: booleanfrom the internalUrllibRequestOptionsinsrc/index.tsinto the publicRequestOptionstype insrc/Request.ts. UrllibRequestOptionsnow inheritsrejectUnauthorizedviaextends RequestOptions.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/index.ts | Removes the internal-only rejectUnauthorized option from UrllibRequestOptions now that it’s provided by RequestOptions. |
| src/Request.ts | Adds rejectUnauthorized?: boolean to the exported RequestOptions type (with JSDoc). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| /** | ||
| * If `true`, the server certificate is verified against the list of supplied CAs. | ||
| * If verification fails, the request promise is rejected. | ||
| * | ||
| * This option is only effective when using the top-level request/curl wrapper with | ||
| * its default dispatcher. It may be ignored when using `HttpClient.request()` | ||
| * directly or when `dispatcher` is explicitly provided. | ||
| * | ||
| * Default: `true` | ||
| */ | ||
| rejectUnauthorized?: boolean; |
There was a problem hiding this comment.
RequestOptions is also the options type for HttpClient.request(), but HttpClient never reads options.rejectUnauthorized (it only comes from ClientOptions.connect.rejectUnauthorized or a provided dispatcher). With this change, TypeScript will now accept httpclient.request(url, { rejectUnauthorized: false }), but it will be a no-op at runtime. Consider scoping this to a wrapper-only options type (e.g. exporting a separate UrllibRequestOptions) or implementing per-request handling so the type matches behavior.
Move `rejectUnauthorized` from the private `UrllibRequestOptions` interface to the public `RequestOptions` type so it can be passed to the top-level `request()`/`curl()` wrapper without a TypeScript error and without constructing a custom HttpClient. Since `allowH2` is already part of `RequestOptions`, the private `UrllibRequestOptions` interface became redundant and is removed; `request()`/`curl()` now use `RequestOptions` directly.
87fe4b2 to
493446b
Compare
rejectUnauthorizedproperty to theRequestOptionstype insrc/Request.tsrejectUnauthorizedfrom the privateUrllibRequestOptionsinterface insrc/index.tsrejectUnauthorizedis accepted onRequestOptionstype